<%@ Page Language="C#" MasterPageFile="~/MasterPageMcSigAdmin.master" AutoEventWireup="true"
    CodeFile="PermisosEpes.aspx.cs" Inherits="PermisosEpes" Title="Untitled Page" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.3.Export, Version=9.3.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>    
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.3, Version=9.3.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.3, Version=9.3.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:SqlDataSource ID="SqlDataSourcePermisosEpes" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
        SelectCommand="SELECT     ADM_PERMISOS_EPES.PEE_ID, TIPO_PERMISOS_EPES.TPE_ID, TIPO_PERMISOS_EPES.TPE_NOMBRE, ADM_USUARIOS.USU_ID, &#13;&#10;                      ADM_USUARIOS.USU_NOMBRE, SIG_PLAN_ACCION.PLN_ID, SIG_PLAN_ACCION.PLN_NOMBRE, SIG_PLAN_ACCION.PLN_ANO, &#13;&#10;                      ADM_USUARIOS.USU_ESTADO&#13;&#10;FROM         ADM_PERMISOS_EPES INNER JOIN&#13;&#10;                      ADM_USUARIOS ON ADM_PERMISOS_EPES.USU_ID = ADM_USUARIOS.USU_ID INNER JOIN&#13;&#10;                      TIPO_PERMISOS_EPES ON ADM_PERMISOS_EPES.TEP_ID = TIPO_PERMISOS_EPES.TPE_ID LEFT OUTER JOIN&#13;&#10;                      SIG_PLAN_ACCION ON ADM_PERMISOS_EPES.PLN_ID = SIG_PLAN_ACCION.PLN_ID"
        DeleteCommand="DELETE FROM [ADM_PERMISOS_EPES] WHERE [PEE_ID] = @PEE_ID" 
        InsertCommand="INSERT INTO dbo.ADM_PERMISOS_EPES ( USU_ID, TEP_ID, PLN_ID )VALUES  (@USU_ID ,@TPE_ID,@PLN_ID)"
        UpdateCommand="UPDATE ADM_PERMISOS_EPES SET USU_ID = @USU_ID, TEP_ID = @TPE_ID, PLN_ID = @PLN_ID WHERE [PEE_ID] = @PEE_ID ">
        <DeleteParameters>
            <asp:Parameter Name="PEE_ID" Type="Decimal" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="USU_ID" Type="Decimal" />
            <asp:Parameter Name="TPE_ID" Type="Decimal" />
            <asp:Parameter Name="PLN_ID" Type="Decimal" />
            <asp:Parameter Name="PEE_ID" Type="Decimal" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="USU_ID" Type="Decimal" />
            <asp:Parameter Name="TPE_ID" Type="Decimal" />
            <asp:Parameter Name="PLN_ID" Type="Decimal" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceRubros" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
        SelectCommand="SELECT [PLN_ID], CONVERT(VARCHAR(10),[PLN_ANO]) + ' ' +  [PLN_NOMBRE]    AS PLN_NOMBRE  FROM [SIG_PLAN_ACCION]">
    </asp:SqlDataSource>
    <br />
    <asp:SqlDataSource ID="SqlDataSourceUsuarios" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
        SelectCommand="SELECT [USU_ID], [USU_NOMBRE] FROM [ADM_USUARIOS]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceTipoPermisos" runat="server" ConnectionString="<%$ ConnectionStrings:MCSIGConnectionString %>"
        SelectCommand="SELECT [TPE_ID], [TPE_NOMBRE] FROM [TIPO_PERMISOS_EPES]"></asp:SqlDataSource>
    &nbsp;<dxwgv:aspxgridviewexporter id="gridExport" runat="server" gridviewid="ASPxGridView1"> </dxwgv:aspxgridviewexporter><dx:ASPxGridView ID="ASPxGridView1" runat="server" CssFilePath="~/App_Themes/PlasticBlue/{0}/styles.css"
        CssPostfix="PlasticBlue" AutoGenerateColumns="False" DataSourceID="SqlDataSourcePermisosEpes"
        KeyFieldName="PEE_ID">
        <Styles CssPostfix="PlasticBlue" CssFilePath="~/App_Themes/PlasticBlue/{0}/styles.css">
            <Header SortingImageSpacing="10px" ImageSpacing="10px">
            </Header>
        </Styles>
        <SettingsPager ShowDefaultImages="False">
            <AllButton Text="All">
            </AllButton>
            <NextPageButton Text="Next &gt;">
            </NextPageButton>
            <PrevPageButton Text="&lt; Prev">
            </PrevPageButton>
        </SettingsPager>
        <ImagesFilterControl>
            <LoadingPanel Url="~/App_Themes/PlasticBlue/Editors/Loading.gif">
            </LoadingPanel>
        </ImagesFilterControl>
        <Images SpriteCssFilePath="~/App_Themes/PlasticBlue/{0}/sprite.css">
            <LoadingPanelOnStatusBar Url="~/App_Themes/PlasticBlue/GridView/gvLoadingOnStatusBar.gif">
            </LoadingPanelOnStatusBar>
            <LoadingPanel Url="~/App_Themes/PlasticBlue/GridView/Loading.gif">
            </LoadingPanel>
        </Images>
        <StylesEditors>
            <CalendarHeader Spacing="11px">
            </CalendarHeader>
            <ProgressBar Height="25px">
            </ProgressBar>
        </StylesEditors>
        <Columns>
            <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                <EditButton Visible="True">
                </EditButton>
                <NewButton Visible="True">
                </NewButton>
                <DeleteButton Visible="True">
                </DeleteButton>
                <ClearFilterButton Visible="True">
                </ClearFilterButton>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="PEE_ID" ReadOnly="True" VisibleIndex="1">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="TPE_NOMBRE" VisibleIndex="2">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Estado" FieldName="TPE_ID" VisibleIndex="1"
                Visible="False" Width="300px">
                <EditFormSettings Visible="True" />
                <PropertiesComboBox CallbackPageSize="15" TextField="TPE_NOMBRE" ValueField="TPE_ID"
                    DataSourceID="SqlDataSourceTipoPermisos" EnableCallbackMode="True" EnableIncrementalFiltering="True"
                    ValueType="System.String">
                </PropertiesComboBox>
                <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" ShowFilterRowMenu="True" />
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn FieldName="USU_NOMBRE" VisibleIndex="3">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Usuario" FieldName="USU_ID" VisibleIndex="1"
                Width="300px">
                <EditFormSettings Visible="True" />
                <PropertiesComboBox CallbackPageSize="15" TextField="USU_NOMBRE" ValueField="USU_ID"
                    DataSourceID="SqlDataSourceUsuarios" EnableCallbackMode="True" EnableIncrementalFiltering="True"
                    ValueType="System.String">
                </PropertiesComboBox>
                <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" ShowFilterRowMenu="True" />
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn FieldName="PLN_NOMBRE" Caption="PLN_NOMBRE" ReadOnly="True"
                VisibleIndex="4" Width="300px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Rubro" FieldName="PLN_ID" VisibleIndex="1"
                Visible="False" Width="300px">
                <EditFormSettings Visible="True" />
                <PropertiesComboBox CallbackPageSize="15" TextField="PLN_NOMBRE" ValueField="PLN_ID"
                    DataSourceID="SqlDataSourceRubros" EnableCallbackMode="True" EnableIncrementalFiltering="True"
                    ValueType="System.String">
                </PropertiesComboBox>
                <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" ShowFilterRowMenu="True" />
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn FieldName="PLN_ANO" VisibleIndex="6">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="USU_ESTADO" VisibleIndex="5">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
        </Columns>
        <Settings ShowFilterRow="True" ShowGroupPanel="True" />
    </dx:ASPxGridView>
    <asp:Button ID="btnXlsExport" runat="server" CssClass="button m tp-space10" OnClick="btnXlsExport_Click"
        Text="Exportar a XLS" />
</asp:Content>
